﻿Type.registerNamespace('AjaxControlToolkit');

AjaxControlToolkit.ImageButtonBehavior = function(element) {

AjaxControlToolkit.ImageButtonBehavior.initializeBase(this, [element]);

	this._targetButtonIDValue = null;
	this._disabledTextValue = null;

}

AjaxControlToolkit.ImageButtonBehavior.prototype = {

	initialize: function() {
		AjaxControlToolkit.ImageButtonBehavior.callBaseMethod(this, 'initialize');

//		$addHandler(this.get_element(), 'keyup',
//        Function.createDelegate(this, this._onkeyup));
		//		this._onkeyup();

		var e = $get(this._targetButtonIDValue);

		$addHandler(e, 'onclick',
        Function.createDelegate(this, this._onclick));
		this._onclick();
	},

	dispose: function() {
		// Cleanup code

		AjaxControlToolkit.ImageButtonBehavior.callBaseMethod(this, 'dispose');
	},

	// Property accessors 
	//
	get_TargetButtonID: function() {
		return this._targetButtonIDValue;
	},

	set_TargetButtonID: function(value) {
		this._targetButtonIDValue = value;
	},

	get_DisabledText: function() {
		return this._disabledTextValue;
	},

	set_DisabledText: function(value) {
		this._disabledTextValue = value;
	},

//	_onkeyup: function() {

//		var e = $get(this._targetButtonIDValue);
//		if (e) {
//			var disabled = ("" == this.get_element().value);
//			e.disabled = disabled;
//			if (this._disabledTextValue) {
//				if (disabled) {
//					this._oldValue = e.value;
//					e.value = this._disabledTextValue;
//				}
//				else {
//					if (this._oldValue) {
//						e.value = this._oldValue;
//					}
//				}
//			}
//		}
//	},

	_onclick: function() {
		alert("test");
	}

}

AjaxControlToolkit.ImageButtonBehavior.registerClass('AjaxControlToolkit.ImageButtonBehavior', AjaxControlToolkit.BehaviorBase);

